package tp.pr2;

/**
 * The superclass of every type of item. It contains the common information for
 * all the items and it defines the interface that the items must match
 * 
 */
public abstract class Item {
	protected String id;
	protected String description;

	/**
	 * Builds an item from a given identifier and description
	 * 
	 * @param id
	 *            - Item identifier
	 * @param description
	 *            - Item description
	 */
	public Item(String id, String description) {
		this.id = id;
		this.description = description;
	}

	/**
	 * Checks if the item can be used. Subclasses must override this method
	 * 
	 * @return true if the item can be used
	 */
	public abstract boolean canBeUsed();

	/**
	 * Try to use the item with a robot in a given place. It returns whether the
	 * action was completed. Subclasses must override this method
	 * 
	 * @param r
	 *            - The robot that uses the item
	 * @param p
	 *            - The Place where the item is used
	 * @return true if the action was completed. Otherwise, it returns false
	 */
	public abstract boolean use(RobotEngine r, Place p);

	/**
	 * Return the item identifier
	 * 
	 * @return the item identifier
	 */
	public java.lang.String getId() {

		return id;
	}

	/**
	 * Generates a String with the Item description. Overrides toString() in
	 * java.lang.Object.
	 */
	public java.lang.String toString() {
		return id + ": " + description;
	}
}
